﻿@model GosWeb.Models.Db.Biont
@{
    ViewBag.Title = "详细资料 "+ @Model.BiontID;
}
@{
    string dieStyle = "style =\"color:Green\"";
    if (Model.FromTo == (int)GosWeb.Models.Db.FromToType.Died)
    {
        dieStyle = "style =\"color:Gray\"";
    }

    string gRatioStyle = "style =\"color:Green\"";
    if (Model.IsGeneRatioCompletion() == false)
    {
        gRatioStyle = "style =\"color:Red\"";
    } 
}
@*<script src="@Url.Content("~/Scripts/jquery-1.4.4.min.js")" type="text/javascript"></script>*@
<fieldset>
    <legend>个体详细资料 （Biont Detail Information） [ @Html.ActionLink("编辑", "Edit", new { id = Model.BiontID })
        | @Html.ActionLink("打印版", "PrintAncestorTree", new { id = Model.BiontID }, new { title = "按Ctrl键+点击:可在新窗口中打开" })
        | @Html.ActionLink("复制", "CopyIt", new { id = Model.BiontID }, new { title = "按Ctrl键+点击:可在新窗口中打开" })
        ]
         </legend>
    <table>
        <tr>
            <td class="display-label">
                @Html.LabelFor(model => model.BiontID)
            </td>
            <td class="display-field">@Model.BiontID
            </td>   
            <td class="display-label">
                @Html.LabelFor(model => model.Sex)
            </td>
            <td class="display-field">@Model.SexStr
            </td>
            <td class="display-label">
                @Html.LabelFor(model => model.Birthday)
            </td>
            <td class="display-field">@String.Format("{0:D}", Model.Birthday)
            </td>      
        </tr>
        <tr>
            <td class="display-label">
                @Html.LabelFor(model => model.FatherID)
            </td>
            <td class="display-field">
            @if (string.IsNullOrWhiteSpace(Model.FatherID) == false)
            {
            @Html.ActionLink(Model.FatherID, "Details", new { id = Model.FatherID })
            }
            else
            {
                string wu = "无";
                @wu
            }
            </td>
            <td class="display-label">
                @Html.LabelFor(model => model.MotherID)
            </td>
            <td class="display-field">
                @if (string.IsNullOrWhiteSpace(Model.MotherID) == false)
                {
                    @Html.ActionLink(Model.MotherID, "Details", new { id = Model.MotherID })
                }
                else
                {
                string wu = "无";
                @wu
                }
            </td>
            <td class="display-label">
                @Html.LabelFor(model => model.NestNumber)
            </td>
            <td class="display-field">@Model.NestNumber
            </td>
        </tr>
 <tr>
             <td class="display-label">
                @Html.LabelFor(model => model.LeftTitNumber)
            </td>
            <td class="display-field">@Model.LeftTitNumber
            </td>
             <td class="display-label">
                @Html.LabelFor(model => model.RightTitNumber)
            </td>
            <td class="display-field">@Model.RightTitNumber
            </td>
            <td class="display-label">
                @Html.LabelFor(model => model.Address.Site)
            </td>
            <td class="display-field">@GosWeb.Biz.BiontBiz.GetInstance().GetSiteString(Model.Address.Site)
            </td>
        </tr>

        <tr >
            <td class="display-label">
                @Html.LabelFor(model => model.GenesShortStr)
            </td>
            <td class="display-field" @Html.Raw(gRatioStyle)>@Model.GenesShortStr (@Model.GetGenesEngStr())
            </td> 
            <td class="display-label">
                血统总计
            </td>
            <td class="display-field" title="如果不是 100%,请检查血统数据是否有问题" @Html.Raw(gRatioStyle)>@Model.SumGeneRatio().ToString("####.##") %
            </td>  <td class="display-label">
                @Html.LabelFor(model => model.FromTo)
            </td>
            <td class="display-field" @Html.Raw(dieStyle)>@Model.FromToStr
            </td>  
        </tr>
        <tr >
            <td class="display-label">
                ID
            </td>
            <td class="display-field" colspan="3">
               @Model.GetLongID()
            </td>
            <td class="display-label">
               @Html.LabelFor(model => model.Weight):
            </td>
            <td class="display-field">@Model.Weight kg
            </td> 
        </tr>
        <tr>
            <td class="display-label">
                同窝数:
            </td>
            <td class="display-field" colspan="5">
                @GosWeb.Biz.BiontBiz.GetInstance().GetCountOfSameNest(Model)
            </td>
        </tr>
        <tr>
            <td class="display-label">
                @Html.LabelFor(model => model.PrivInfo)
            </td>
            <td class="display-field" colspan="5">
                <pre>@Model.PrivInfo</pre>
            </td>
        </tr>
        <tr>
            <td class="display-label">
                @Html.LabelFor(model => model.PubInfo)
            </td>
            <td class="display-field" colspan="5">
                <pre>@Model.PubInfo</pre>
            </td>
        </tr>
 
    </table>
</fieldset>
@if (Model.GeneRatios != null && Model.GeneRatios.Count > 0)
{
<fieldset>
    <legend>品种详细信息 [@Html.ActionLink("新建", "../GRatio/Create", new { id = Model.BiontID })]</legend>
    <table>
        <tr>
            <th>
            </th>
            <th>
                血统代码
            </th>
            <th>
                血统名
            </th>
            <th>
                占比 %
            </th>
        </tr>
        @foreach (var gr in Model.GeneRatios)
        {
            <tr>
                <td>
                </td>
                <td>
                    @Html.ActionLink(gr.GeneCode, "../GRatio/Edit", new { id = gr.GrID })
                </td>
                <td>
                    @GosWeb.Biz.GeneBiz.GetInstance().GetGeneName(gr.GeneCode)
                </td>
                <td>
                    @String.Format("{0:F}", gr.Ratio)
                </td>
            </tr>

        }
    </table>
</fieldset>
}
else if(Model.NoFatherMother() )
{
    <fieldset style="font-size:large">
    <legend style="color:Red"> 请设定品系信息 </legend>
    <p >
        既没指定父母，又没设定血缘信息，可能会引起后续计算错误!<br />
        如果有父母必须<a href="../Edit/@Model.BiontID">设定父母关系</a>，否则请<a href="../../GRatio/Create/@Model.BiontID">设定血缘信息</a>
    </p>
</fieldset>
}


<fieldset>
    <legend>疾病记录 (Medical Records) [ @Html.ActionLink("新建", "../MedicalRecord/Create", new { id = Model.BiontID })
        ]</legend>
    <span  id="MedicalRecord_List">
        正在载入... ...
    </span>
</fieldset>
<br />
@if ((string.IsNullOrWhiteSpace(Model.FatherID) == false) || (string.IsNullOrWhiteSpace(Model.MotherID) == false))
{
    <fieldset>
        <legend>祖先树 (Pedigree Tree)</legend>
        <ul id="PedigreeTree">
            <li><img src='../../Content/Pic/float_loading.gif'></img>正在载入... ...</li>
        </ul>
    </fieldset>
}

<fieldset>
    <legend>它的后代列表 (Pedigree Tree)</legend>
    <span id="SonDaughters">
        <button id="btSonD" onclick="btSonD_click()">
            点击载入</button>
    </span>
</fieldset>

<script type="text/javascript">
    $(document).ready
    (
        function () {
            var bid = "@Model.BiontID";
            //---------
            $.get("/Biont/GetAncestorTree?layer=2&BID=" + bid,
                { Action: "get" },
                function (data, textStatus) {
                    this;
                    //alert(data);
                    document.getElementById('PedigreeTree').innerHTML = data;
                }
            );
            //------------
            $.get("/MedicalRecord/GetRecords?id=" + bid,
                { Action: "get" },
                function (data, textStatus) {
                    this;
                    //alert(data);
                    document.getElementById('MedicalRecord_List').innerHTML = data;
                }
            );
            //-------------
        }
    ) 
</script>
<script type="text/javascript">
    function btSonD_click() {
        var bid = "@Model.BiontID";
        document.getElementById('SonDaughters').innerHTML = "<img src='../../Content/Pic/float_loading.gif'></img>正在载入,请稍后...";
        $.get("/Biont/SonDaughters?id=" + bid,
                { Action: "get" },
                function (data, textStatus) {
                    this;
                    //alert(data);
                    document.getElementById('SonDaughters').innerHTML = data;
                }
            );
    }

</script>
